package com.uptech.homer.util;

import com.uptech.homer.beans.CanInfo;

import java.io.Serializable;
import java.text.Collator;
import java.util.Comparator;

public class ComparatorSerializable<T> implements Comparator<CanInfo>, Serializable {

    private static final long serialVersionUID = 1L;

    @Override
    public int compare(CanInfo o1,
                       CanInfo o2) {

        Collator cmp = Collator.getInstance(java.util.Locale.CHINA);

        String s1 = o1.getKey() + "";
        String s2 = o2.getKey() + "";

        if (cmp.compare(s1, s2) > 0) {
            return 1;
        } else if (cmp.compare(s1, s2) < 0) {
            return -1;
        }

        return 0;
    }

}
